package controller.command;

import model.spring.AbstractAddress;
import model.spring.AddressList;

public class Delete extends Command {
	
	private AbstractAddress address;
	private int index;
	private int position;
	
	public Delete(int position){
		this.position = position;
	}
	
	@Override
	public void execute() {
		if(position != -1) {
			address = AddressList.getInstance().get(position);
			AddressList.getInstance().remove(position);
		}
	}
	
	public void undo() {
		if(index != -1) 
			AddressList.getInstance().add(address,position);
	}
}
